package com.xm.proxy;

import java.lang.reflect.Proxy;

public class JavaProxyFactory {
    public static Object getProxy(Object target) {
        MyInvocationHandler handler = new MyInvocationHandler(target);
        //设置类加载器
        ClassLoader classLoader = target.getClass().getClassLoader();
        //设置实现接口数组
        Class<?>[] interfaces = target.getClass().getInterfaces();
        //生成代理类实例
        return Proxy.newProxyInstance(classLoader, interfaces, handler);
    }
}
